<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="crm.util.ParamUtil"%>
<%@page import="crm.model.Recepit_description"%>
<%@page import="crm.model.Recepit"%>
<%@page import="java.util.Collection"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Iterator"%>
<%@page import="crm.control.RecepitControl"%>
<%@page import="crm.control.CustomerControl"%>
<%@page import="crm.control.LinkmanControl"%>
<%@page import="crm.util.GetBaseParam"%>
<%@page import="crm.control.RecepitDescriptionControl"%>
<%@page import="crm.control.EmployeesControl"%>
<%@page import="crm.control.BargainControl"%>
<%@page import="crm.model.Employees"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../resources/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../resources/css/inner.css" type="text/css" media="screen" />
<style type='text/css'>
 a{font-size:12px; text-decoration:none; color:#70B300;}
</style>
<title>Insert title here</title>
<script type="text/javascript"
		src="../../../resources/js/jquery-1.6.2.min.js"></script>
	<script type="text/javascript">
	$(function(){
           $('#show_add_money').hide();
           $('#add_money').click(function(){
    				$('#show_add_money').slideToggle();
               })
               $('#cancel').click(function(){
 						$('#show_add_money').fadeOut();
                   })
                   $('input:text').click(function(){
				return false;
				})

		})
	
	</script>
</head>
<body>
<div class='init'>
<%
               request.setCharacterEncoding("utf-8");
               int recepitId = ParamUtil.getInt(request,"id",0);
               Recepit re = RecepitControl.getRecepitById(recepitId);
               Employees cu = (Employees)session.getAttribute("user");
%>
<form>
<table>
<caption class='title'>
跟单信息
</caption>
       <tr><td>项目名称</td><td><%=re.getTitle() %></td></tr>
       <tr><td>客户</td><td><%=CustomerControl.getCustomerById(re.getConsumer_id()).getName() %></td></tr>
       <%if(re.getLinkman_id()>0){ %>
       <tr><td>联系人</td><td><%=LinkmanControl.getLinkmanName(re.getLinkman_id()) %></td></tr>
       <tr><td>联系人电话</td><td><%=LinkmanControl.getLinkmanById(re.getLinkman_id()).getPhone() %></td></tr>
       <%} %>
       <tr><td>创建人</td><td><%=re.getCreator() %></td></tr>
       <tr><td>状态</td><td><%=GetBaseParam.getStageById(re.getStage()) %></td></tr>
       <%
        if(re.getStage()==5){
        	%>
        	<tr><td>总共已回款金额</td><td><%=RecepitControl.getTotalHuiKuan(recepitId) %>元</td></tr>
        	<%
        }
       %>
       <tr><td>分类</td><td><%if(re.getSort()!=null&&re.getSort().equals("0")) out.print("一般"); else out.print("重要"); %></td></tr>
       <tr><td>当前跟单人</td><td><%=EmployeesControl.getEmpolyeesById(re.getCurrent_person()).getName() %></td></tr>
       <tr><td>预计成交时间</td><td><%=re.getPredict_time() %></td></tr>
       <tr><td>预计成交金额</td><td><%=re.getPredict_amount() %>元</td></tr>
       <%
            String p[] = re.getPrduct().split("@");
       %>
</table>
<table>
<caption class='title'>产品</caption>
       <tr><td>天成软件</td><td><%=p[1] %></td> </tr>
       <tr><td>第三方软件</td><td><%=p[2] %></td> </tr>
       <tr><td>相关硬件</td><td><%=p[3] %></td> </tr>
</table>
</form>
<form>
<table>
<caption class='title'>
跟单移交记录
</caption>
<thead>
<tr>
	<td>跟单人</td>
	<td>开始阶段</td>
	<td>结束阶段</td>
	<td>回款金额</td>
</tr>
</thead>
<%
      String person1 = re.getPerson1();
      String p1[]  =person1.split("@");
%>
<tbody>
<tr>
	<td><%=EmployeesControl.getEmployeesName(Integer.parseInt(p1[1])) %></td>
	<td><%=GetBaseParam.getStageById(Integer.parseInt(p1[2])) %></td>
	<td><%if(!p1[3].equals("0")) out.print(GetBaseParam.getStageById(Integer.parseInt(p1[3])));  else{out.print("（进行中...）");}%></td>
	<td><%=Float.parseFloat(p1[4]) %>元</td>
</tr>
  <%
        String person2 = re.getPerson2();
  String p2[] = person2.split("@");
  if(person2!=null&&!person2.equals("")){
  %>
	  <tr><td><%=EmployeesControl.getEmployeesName(Integer.parseInt(p2[1])) %></td>
      <td><%=GetBaseParam.getStageById(Integer.parseInt(p2[2])) %></td>
       <td><%if(!p2[3].equals("0")) out.print(GetBaseParam.getStageById(Integer.parseInt(p2[3])));  else{out.print("（进行中...）");}%></td>
       <td><%=Float.parseFloat(p2[4]) %>元</td>
       </tr>
	 <% 
  }
  %>
   <%
        String person3 = re.getPerson3();
   String p3[] = person3.split("@");
  if(person3!=null&&!person3.equals("")){
  %>
	  <tr><td><%=EmployeesControl.getEmployeesName(Integer.parseInt(p3[1])) %></td>
      <td><%=GetBaseParam.getStageById(Integer.parseInt(p3[2])) %></td>
       <td><%if(!p3[3].equals("0")) out.print(GetBaseParam.getStageById(Integer.parseInt(p3[3])));  else{out.print("（进行中...）");}%></td>
       <td><%=Float.parseFloat(p3[4]) %>元</td>
       </tr>
	 <% 
  }
  %>
  </tbody>
</table>
</form>
<%if(RecepitControl.getTransferRecordNumber(recepitId)<4&&re.getCurrent_person()==cu.getId()){%>
<p class='title'><a href="transform_recepit.jsp?id=<%=recepitId %>">进行跟单移交</a></p>
<%} %>
<%if(re.getStage()<3){ %>
<p class='title'><a href="turn_to_offer.jsp?id=<%=recepitId %>">申请转入报价</a><%} %></p>
<%if(re.getStage()>=5) {%>
	<p class='title'><input type="button" class='button' value="添加回款金额" id="add_money" /></p>
		<div style='height:80px;'>
		<div id="show_add_money" >
                     <form id="form1" name="form1" method="post" action="../bargain/add_returned_money.jsp?id=<%=BargainControl.getBargainIdByRecepitId(recepitId)%>">
                     <p>输入金额：<input  type="text" style="width:190px;" name="add_money"  />
                      <select name="danwei"><option value="0">元</option><option value="1">万元</option></select></p> 
                      <p>确认金额：<input  type="text" style="width:190px;" name="add_money2"  />
                      <select name="danwei2"><option value="0">元</option><option value="1">万元</option></select>
                      </p>
                      <p class='title'><input  type="submit" class="btn_tag button" value="确定" />&nbsp;&nbsp;&nbsp;
                      <input  type="button"  id="cancel" class='button' value="取消" /></p>
                    </form>
	</div>
	</div>	
<%} %>
<br/>
<table>
<caption class='title'>跟单信息</caption>
      <%
           Collection description=new ArrayList();
           description = RecepitDescriptionControl.getAllRecepitDescriptions(recepitId);
           Iterator iterator = description.iterator();
           while(iterator.hasNext()){
           Recepit_description r=(Recepit_description)iterator.next();
       %>
       <tr>
       <td>
		<%=EmployeesControl.getEmpolyeesById(r.getFollow_person_id()).getName()%>(<%=r.getDate() %> )</td>
		</tr>
		<tr>
		<td>
        <%=r.getContent() %>
        </td>
        </tr>      
       <%} %>
       </table>
<a class='button' href="recepit_description_add.jsp?id=<%=recepitId %>">添加跟进信息</a>
</div>
</body>
</html>